$(function(){
	init();
});
function init(){
	e();
	s();
}

function e(){
	
}

// swiper初始化
function s(){
    // 首页banner
    homeBanner = new Swiper(".homeBanner",{
        slidesPerView: 1,
        autoplay: 3000,
        loop: true,
        pagination : '.homeBanner-pagination',
        paginationClickable :true
    });
    $(".homeBanner").hover(function () {
        homeBanner.stopAutoplay();
    }, function () {
        homeBanner.startAutoplay();
    });
}

public_class();         // 公开课-内文高度
public_class_select();  // 公开课展示选择

function public_class() {
    var le_height = $(".le-public-class .post-list").height();
    var post_num = $(".le-public-class .post-list").length;
    var post_row = Math.ceil(post_num/3);
    var le_content_height = le_height*post_row+50;
    $(".le-public-class .part2 > .part-cont").css("height",le_content_height+300);

    var f=0;
    $(".le-public-class .post-data").click(function() {
        if(f==0){
            f=1;
            $(".le-public-class .post-data").removeClass("activity");
            $(this).addClass("activity");

            var le_all_content_height = $(".le-public-class .activity .post-allcontent").height();
            var sum_height = (le_content_height+le_all_content_height+300);
            $(".le-public-class .part2 > .part-cont").css("height",sum_height);


            $(".post-head .play-bottom").slideUp("slow");
            $(".post-allcontent").slideUp("slow");

            $(this).find(".post-head .play-bottom").fadeIn("slow");
            $(this).find(".post-foot .post-word .post-allcontent").slideDown("slow");
            $(this).find(".post-allcontent").slideDown("slow");
            $(this).find(".post-abbreviation").fadeIn("slow");

            //$(this).css("animation","s_to_big 0.8s");
        }
        else{
            f=0;
            $(".le-public-class .post-data").removeClass("activity");

            $(".le-public-class .part2 > .part-cont").css("height",le_content_height+300);


            $(".post-head .play-bottom").fadeOut("slow");
            $(".post-foot .post-word .post-allcontent").slideUp("slow");
            $(".post-allcontent").slideUp("slow");

            $(this).find(".post-head .play-bottom").fadeOut("slow");
            $(this).find(".post-foot .post-word .post-allcontent").slideUp("slow");
            $(this).find(".post-allcontent").slideUp("slow");
            $(this).find(".post-abbreviation").fadeIn("slow");
            //$(this).css("animation","big_to_s 0.8s");
        }
    });
}
function public_class_select() {
    $('.pc-activity-form [name~=grade]').css('color','#9e9e9e');
    $('.pc-activity-form [name~=grade]').change(function() {
        var current = $('.pc-activity-form [name~=grade]').val();
        if (current != '') {
            $('.pc-activity-form [name~=grade]').css('color','#333333');
        } else {
            $('.pc-activity-form [name~=grade]').css('color','#9e9e9e');
        }
    });
    $('.pc-activity-form [name~=subject]').css('color','#9e9e9e');
    $('.pc-activity-form [name~=subject]').change(function() {
        var current = $('.pc-activity-form [name~=subject]').val();
        if (current != '') {
            $('.pc-activity-form [name~=subject]').css('color','#333333');
        } else {
            $('.pc-activity-form [name~=subject]').css('color','#9e9e9e');
        }
    });

    if($(".part-tab .select-item[name~='grade']").length>0){
        if($(".select-item[name~='grade']").val()){
            $(".select-item[name~='grade']").css('color', '#3a7eff');
        }
    }
    if($(".part-tab .select-item[name~='subject']").length>0){
        if($(".select-item[name~='subject']").val()){
            $(".select-item[name~='subject']").css('color', '#3a7eff');
        }
    }
}

/*
function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
}
*/
